package com.tao.mytestgreendao;

import android.database.sqlite.SQLiteStatement;

import com.tao.mytestgreendao.gen.UserEntityDao;
import com.tao.update.BaseUpdataWraper;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;

/**
 * reate by tao on{DATE}
 */
public class UserEntityUpdateWraper<K> extends BaseUpdataWraper<UserEntity, K> {


    public UserEntityUpdateWraper(AbstractDao<UserEntity, K> dao, Property[] permKeys) {
        super(dao, permKeys);
    }

    @Override
    public void bindWheres(int i, UserEntity entity, SQLiteStatement stmt, Property pkColumn) {
        if  (pkColumn == UserEntityDao
                .Properties.Id){

            Long sex = entity.getId();
            if (sex != null) {
                stmt.bindLong(i, sex);
            }
            
        }else if (pkColumn == UserEntityDao
                .Properties.Name){
            String name = entity.getName();
            if (name != null) {
                stmt.bindString(i, name);
            }
            
        }else if (pkColumn == UserEntityDao
                .Properties.Age){
            Integer age = entity.getAge();
            if (age != null) {
                stmt.bindLong(i, age);
            }
        }
           else if (pkColumn == UserEntityDao
                .Properties.Sex){
            Integer age = entity.getSex();
            if (age != null) {
                stmt.bindLong(i, age);
            }
        }
                
        
    }

    @Override
    public void bindUpdateValues(int i, SQLiteStatement stmt, UserEntity entity) {

        switch (i) {
            case 1:
                String name = entity.getName();
                if (name != null) {
                    stmt.bindString(i, name);
                }
                break;
            case 2:
                Integer age = entity.getAge();
                if (age != null) {
                    stmt.bindLong(i, age);
                }
                break;
            case 3:
                Integer sex = entity.getSex();
                if (sex != null) {
                    stmt.bindLong(i, sex);
                }
                break;
            case 4:
                String detail = entity.getDetail();
                if (detail != null) {
                    stmt.bindString(i, detail);
                }
                break;
        }


    }
}
